package thread.mianshi.redPacket;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by sunjian on 2018/7/12.
 */
public class RobRedPacketHandler {

    private static Semaphore semaphore = new Semaphore((int) RedPacketUtil.RedPacket.RED_PACKET_COUNT.getValue());
    /**
     * 红包计数器
     */
    public static int i = 0;
    public static void RobRedPacket(RobRedPacketThread robRedPacketThread){

            synchronized (Main.class){
                if (i==(int) RedPacketUtil.RedPacket.RED_PACKET_COUNT.getValue()){
                    System.out.printf("%s手速过慢，红包已经抢完了\n",robRedPacketThread.getThreadName());
                    return;
                }
                System.out.printf("%s抢到的红包为，%s\n",robRedPacketThread.getThreadName(),Main.redPackets.get(i));
                i++;
            }

    }
}
